package com.oss.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.oss.service.ProjectService;
import com.oss.service.TagService;

/**
 * @author xueqiang.mi
 * @date 2010-2-2
 */
@Controller
public class TagController extends BaseController {

	@Autowired
	private ProjectService prjService;

	@Autowired
	private TagService tagService;

	@RequestMapping("/tag.do")
	public void tagHandler(Model model,
			@RequestParam(value = "id", required = false) String id) {
		if (id == null) {
			id = "blog";
		} else {
			model.addAttribute("id", id);
		}
		model.addAttribute("tag", tagService.get(id));
		model.addAttribute("prjs", prjService.getPrjsByTag("user", id, 1, 50));
	}

}
